function map2Dict(map: { label: string; value: any }[]) {
  const dictionary: { [key: string | number]: string } = {}
  map.forEach((item: any) => {
    dictionary[item.value] = item.label
  })
  return dictionary
}

export const APPLY_STATUS_MAP = [
  {
    label: '待处理',
    value: 0,
  },
  {
    label: '退货中',
    value: 1,
  },
  {
    label: '已完成',
    value: 2,
  },
  {
    label: '已拒绝',
    value: 3,
  },
]

export const APPLY_STATUS_DICT = map2Dict(APPLY_STATUS_MAP)

export const RECOMMEND_STATUS_MAP = [
  {
    label: '未推荐',
    value: 0,
  },
  {
    label: '推荐中',
    value: 1,
  },
]
export const RECOMMEND_STATUS_DICT = map2Dict(RECOMMEND_STATUS_MAP)
export const OPERATE_STATUS_MAP = [
  {
    label: '设为推荐',
    value: 0,
  },
  {
    label: '取消推荐',
    value: 1,
  },
  {
    label: '删除',
    value: 2,
  },
]
export const OPERATE_STATUS_DICT = map2Dict(OPERATE_STATUS_MAP)

export const BRAND_TYPE_MAP = [
  {
    label: '显示品牌',
    value: 'showBrand',
  },
  {
    label: '隐藏品牌',
    value: 'hideBrand',
  },
]
export const BRAND_TYPE_DICT = map2Dict(BRAND_TYPE_MAP)

export const PRODUCT_STATUS_MAP = [
  {
    label: '商品上架',
    value: 'publishOn',
  },
  {
    label: '商品下架',
    value: 'publishOff',
  },
  {
    label: '设为推荐',
    value: 'recommendOn',
  },
  {
    label: '取消推荐',
    value: 'recommendOff',
  },
  {
    label: '设为新品',
    value: 'newOn',
  },
  {
    label: '取消新品',
    value: 'newOff',
  },
  {
    label: '转移到分类',
    value: 'transferCategory',
  },
  {
    label: '移入回收站',
    value: 'recycle',
  },
]
export const PRODUCT_STATUS_DICT = map2Dict(PRODUCT_STATUS_MAP)

export const PUTAWAY_PRODUCT_STATUS_MAP = [
  {
    value: 1,
    label: '上架',
  },
  {
    value: 0,
    label: '下架',
  },
]
export const PUTAWAY_PRODUCT_STATUS_DICT = map2Dict(PUTAWAY_PRODUCT_STATUS_MAP)

export const VERIFY_PRODUCT_STATUS_MAP = [
  {
    value: 1,
    label: '审核通过',
  },
  {
    value: 0,
    label: '未审核',
  },
]
export const VERIFY_PRODUCT_STATUS_DICT = map2Dict(VERIFY_PRODUCT_STATUS_MAP)

export const ORDER_STATUS_MAP = [
  {
    label: '待付款',
    value: 0,
  },
  {
    label: '待发货',
    value: 1,
  },
  {
    label: '已发货',
    value: 2,
  },
  {
    label: '已完成',
    value: 3,
  },
  {
    label: '已关闭',
    value: 4,
  },
]

export const ORDER_STATUS_DICT = map2Dict(ORDER_STATUS_MAP)

export const ORDER_TYPE_MAP = [
  {
    label: '正常订单',
    value: 0,
  },
  {
    label: '秒杀订单',
    value: 1,
  },
]
export const ORDER_TYPE_DICT = map2Dict(ORDER_TYPE_MAP)

export const ORDER_SOURCE_TYPE_MAP = [
  {
    label: 'PC订单',
    value: 0,
  },
  {
    label: 'APP订单',
    value: 1,
  },
]
export const ORDER_SOURCE_TYPE_DICT = map2Dict(ORDER_SOURCE_TYPE_MAP)

export const ORDER_OPERATE_STATUS_MAP = [
  {
    label: '批量发货',
    value: 1,
  },
  {
    label: '关闭订单',
    value: 2,
  },
  {
    label: '删除订单',
    value: 3,
  },
]

export const ORDER_OPERATE_STATUS_DICT = map2Dict(ORDER_OPERATE_STATUS_MAP)

export const LOGISTICS_COMPANIES_SET = new Set(['顺丰快递', '圆通快递', '中通快递', '韵达快递'])

export const PAY_TYPE_DICT: { [key: number]: string } = {
  1: '支付宝',
  2: '微信',
}
export const PAY_STATUS_DICT: { [key: number]: string } = {
  0: '未支付',
  4: '已退款',
}
export const DELIVER_STATUS_DICT: { [key: number]: string } = {
  0: '未发货',
  1: '未发货',
  2: '已发货',
}
export const LEVEL_DICT: { [key: number]: string } = {
  0: '一级',
  1: '二级',
}

export const COUPON_TYPE_MAP = [
  {
    label: '全场赠券',
    value: 0,
  },
  {
    label: '会员赠券',
    value: 1,
  },
  {
    label: '购物赠券',
    value: 2,
  },
  {
    label: '注册赠券',
    value: 3,
  },
]
export const COUPON_TYPE_DICT = map2Dict(COUPON_TYPE_MAP)

export const COUPON_STATUS_MAP = [
  {
    label: '未使用',
    value: 0,
  },
  {
    label: '已使用',
    value: 1,
  },
  {
    label: '已过期',
    value: 2,
  },
]
export const COUPON_STATUS_DICT = map2Dict(COUPON_STATUS_MAP)

export const COUPON_RANGE_MAP = [
  {
    label: '全平台',
    value: 0,
  },
  {
    label: '移动平台',
    value: 1,
  },
  {
    label: 'PC平台',
    value: 2,
  },
]

export const COUPON_RANGE_DICT = map2Dict(COUPON_RANGE_MAP)

export const ADVEERT_TYPE_MAP = [
  {
    label: 'PC首页轮播',
    value: 0,
  },
  {
    label: 'APP首页轮播',
    value: 1,
  },
]
export const ADVEERT_TYPE_DICT = map2Dict(ADVEERT_TYPE_MAP)

export const COUPON_AREA_MAP = [
  { label: '全场通用', value: 0 },
  { label: '指定分类', value: 1 },
  { label: '指定商品', value: 2 },
]

export const COUPON_AREA_DICT = map2Dict(COUPON_AREA_MAP)
